﻿
namespace Huirui.Cavan.Presentation.Seedwork
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.Contracts;
    using System.Linq;
    using Huirui.Cavan.Core.Persistent;

    /// <summary>
    ///     Base class for the standard Entities with int ID
    /// </summary>
    /// <typeparam name = "T">Entity with int ID to be moved between Controller and View</typeparam>
    /// <typeparam name = "TSearch"></typeparam>
    public abstract class EntityModel<T, TSearch> : EntityModel<T, int, TSearch>
        where T : class, IPersistentObjectWithTypedId<int>
        where TSearch : class, ISearch<int> { 
        
    }

    /// <summary>
    ///     Base model for every entity of type T
    ///     containing all needed properties to fill MasterPage
    ///     and to support EntityController actions
    /// </summary>
    /// <typeparam name = "T">Entity with int ID to be moved between Controller and View</typeparam>
    /// <typeparam name = "TID">type of the ID (string is not supported in the base EntityController implemenatation)</typeparam>
    /// <typeparam name = "TSearch"></typeparam>
    public abstract class EntityModel<T, TID, TSearch> : WebModel, IEditModel<T, TID, TSearch>
        where T : class, IPersistentObjectWithTypedId<TID>
        where TSearch : class, ISearch<TID>
    {
        #region T, TSearch
        /// <summary>
        ///     Current Entity Item used on Detail, New and Edit
        /// </summary>
        public virtual T Item { get; set; }

        /// <summary>
        ///     Searching Object for Entity Item
        /// </summary>
        public virtual TSearch SearchParam { get; set; }
        #endregion
    }
}